package com.chc.web.reader.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2022/04/21/21:44
 * @Description:
 */
@Data
@TableName("reader")
public class Reader implements UserDetails,Serializable {

    @TableId(type = IdType.AUTO)
    private Long id;
    //读者登录名
    private String username;
    //读者密码
    private String password;
    //读者姓名
    private String name;
    //读者电话
    private String tel;
    //读者卡号
    private String cardid;
    //读者性别
    private Long gender;

    //角色id不属于业主表，需要排除
    @TableField(exist =  false)
    private Long roleId;
    //帐户是否过期(1 未过期，0已过期)
    @TableField(exist = false)
    private boolean isAccountNonExpired = true;
    //帐户是否被锁定(1 未锁定，0已锁定)
    @TableField(exist = false)
    private boolean isAccountNonLocked = true;
    //密码是否过期(1 未过期，0已过期)
    @TableField(exist = false)
    private boolean isCredentialsNonExpired = true;
    //帐户是否可用(1 可用，0 删除用户)
    @TableField(exist = false)
    private boolean isEnabled = true;
    //由于authorities不是数据库里面的字段，所以要排除他，不然mybatis-plus找不到该字段会报错
    @TableField(exist = false)
    Collection<? extends GrantedAuthority> authorities;
}
